package wj.d908;

import java.lang.ref.*;
import java.util.ArrayList;
import java.util.List;

public class P1 {
    public List<String> solve(String[] nums) {
        List<String> result = new ArrayList<>();
        bt(nums, 0, new ArrayList<>(), result);
        return result;
    }

    private void bt(String[] nums, int begin, List<String> savedList, List<String> result) {
        if (begin == nums.length) {
            result.add(savedList.toString());
        } else {
            bt(nums, begin + 1, savedList, result);
            savedList.add(nums[begin]);
            bt(nums, begin + 1, savedList, result);
            savedList.remove(savedList.size() - 1);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ReferenceQueue<Integer> queue = new ReferenceQueue<>();
        new Thread(() -> {
            Reference<? extends Integer> poll = queue.poll();
            System.out.println("回收:" + poll);
        }).start();
        WeakReference<Integer> abc = new WeakReference(new Integer(1));
        SoftReference<Integer> def = new SoftReference<>(new Integer(1));
        PhantomReference<Integer> g = new PhantomReference<Integer>(new Integer(1), queue);
        System.out.println(g.get());
        System.gc();
        System.out.println(abc.get());
        System.out.println(def.get());
        Thread.sleep(1000 * 10);
    }
}
